//package temporay;
//
//import temporay.message.Request;
//
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.ObjectOutputStream;
//import java.net.InetSocketAddress;
//import java.nio.ByteBuffer;
//import java.nio.channels.SelectionKey;
//import java.nio.channels.Selector;
//import java.nio.channels.SocketChannel;
//import java.util.Iterator;
//import java.util.Set;
//
///**
// * program: io-share
// * author: bsworld.xie
// * create: 2021-04-19 15:04
// * description:
// */
//public class ReactorClient {
//
//    private static long count = 0;
//
//    public static void main(String[] args) throws IOException {
//        SocketChannel socketChannel = SocketChannel.open();
//        Selector selector = Selector.open();
//        socketChannel.configureBlocking(false);
//        socketChannel.connect(new InetSocketAddress("127.0.0.1", 5888));
//        socketChannel.register(selector, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
//        while (true) {
//            selector.select();
//            Set<SelectionKey> selectionKeys = selector.selectedKeys();
//            Iterator<SelectionKey> iterator = selectionKeys.iterator();
//            while (iterator.hasNext()) {
//                SelectionKey sk = iterator.next();
//                if (sk.isReadable()) {
//                    //
//                } else if (sk.isWritable()) {
//                    ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
//                    Request request = new Request();
//                    request.setId(++count);
//                    request.setMsg("hello server:" + count);
////                    socketChannel.write();
//                }
//            }
//        }
//    }
//}
